﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet.Entity.Common.Web;
using BaseSet;
using System.Data;


namespace WebSite
{
    public partial class IndexU : PreBasePage
    {
        public string userid = "";
        public string strseo = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"] + "";
            if (id == "")
            {
                Response.Redirect("../Index.aspx");
                return;
            }
            else
            {
                //判断参数是否为guid类型
                if (Tools.IsGUID(id))
                {
                    UsersHelper uhelper = new UsersHelper();
                    Users uinfo = uhelper.GetUsers(id);
                    string realmname = uinfo.RealmName;
                    if (string.IsNullOrEmpty(realmname))
                    {
                        userid = id;
                    }
                    else
                    {
                        Response.Redirect("../u/"+realmname+".aspx");
                        return;
                    }
                }
                else
                {
                    UsersHelper uhelper = new UsersHelper();
                    userid = uhelper.GetUsersID(id);
                    if (userid == "")
                    {
                        Response.Redirect("../Index.aspx");
                        return;
                    }
                }
                
            }
            //userid = userid.Substring(0, userid.Length - 1);
            if (!Page.IsPostBack)
            {
                BindBlog();
                BindTuWen();//用户图文榜
                BindVideo();//用户视频榜
                BindMP3();//用户MP3榜
                //BindCompany();//该用户加入的小组
                BindCareCompany();//该用户关注的小组
                BindCareUser();//该用户关注的创作人
                BindRecommand();//该用户推荐
                BindNowRead();//用户正在阅读
                BindSeo();
                //BindBlogPic();
                BindPV();//加载PV
                BindAd();//加载广告
            }
        }

        #region 加载博客
        private void BindBlog()
        {
            //当前用户数据
            Users uinfo = new Users();
            UsersHelper uhelper = new UsersHelper();
            uinfo = uhelper.GetUsers(userid);
            string currentusernickname = uinfo.NickName;
            string headphoto = uinfo.SmallHeadImage;
            if (string.IsNullOrEmpty(headphoto))
            {
                headphoto = "../images/morentouxiang.jpg";
            }
            imghead.ImageUrl = headphoto;
            imghead.ToolTip = currentusernickname;
            litNickName1.Text = currentusernickname;
            litNickName2.Text = currentusernickname;
            litNickName3.Text = currentusernickname;
            //litNickName4.Text = currentusernickname;
            litNickName5.Text = currentusernickname;
            //litNickName6.Text = currentusernickname;
            litNickName7.Text = currentusernickname;
            litNickName8.Text = currentusernickname;
            litNickName9.Text = currentusernickname;
            litNickName10.Text = currentusernickname;

            litBrief.Text = uinfo.Brief;
            litBlogNum.Text = uinfo.BlogNum.ToString();
            litToBeFriendNum.Text = uinfo.ToBeFriendNum.ToString();
            litBlogPVNum.Text = uinfo.BlogPVNum.ToString();
            litFriendNum.Text = uinfo.FriendNum.ToString();
            hidBlogUserID.Value = userid;
            //当前用户的权限
            string roleid = uinfo.RoleID;
            Role roleinfo = new Role();
            RoleHelper rolehelper = new RoleHelper();
            roleinfo = rolehelper.GetRole(roleid);
            litRoleName.Text = roleinfo.RoleName;

            //用户的页面 加载该用户发表的博客
            //设置控件属性，从BasePage中得到
            PageConfig(BlogUPager);

            //List<Member> list = new List<Member();
            BlogHelper bhelper = new BlogHelper();
            Criteria c = new Criteria();

            //加载有效
            c.Add(CriteriaType.Equals, "Flag", 0);
            c.Add(CriteriaType.Equals, "UsersID", userid);
            
            BlogUPager.ItemCount = bhelper.QueryBlogCountBySearch(c);

            // 以下的值从BasePage中得到
            BlogUPager.UrlFormat = UrlFormat;
            //BlogUPager.PrefixText = GetPreFixText(BlogUPager);

            string[] fields = new string[] { "ID", "BlogBigType", "BlogTypeName", "BlogTypeID", "Title", "BlogContent", "UsersID", "UserRealmName", "NickName", "PVCount", "ReplyCount", "RecommandCount", "HasPic", "Flag", "CreateDate" };

            DataTable dt = new DataTable();
            dt = bhelper.QueryBlogBySearchToTable(c, new Order[] { new Order("CreateDate", OrderMode.Desc) }, BlogUPager.Begin - 1, BlogUPager.Count, fields);

            dt.Columns.Add(new DataColumn("strCreateDate"));
            dt.Columns.Add(new DataColumn("strBlogContent"));
            dt.Columns.Add(new DataColumn("strHasPic"));
            dt.Columns.Add(new DataColumn("strVideoPic"));

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    DateTime dtCreateDate = Convert.ToDateTime(dr["createdate"]);
                    dr["strCreateDate"] = dtCreateDate.ToString("yyyy-MM-dd HH:mm");

                    //截取内容
                    string blogcontent = Server.HtmlDecode(dr["BlogContent"] + "");
                    //将内容中的html代码去掉
                    blogcontent = Tools.NoHTML(blogcontent);
                    string strblogcontent = Tools.GetFirstString(blogcontent, 160);
                    if (strblogcontent != "")
                    {

                        dr["strBlogContent"] = "<p class=\"post_item_summary\" ><a href=\"../u/" + userid + ".aspx\" target=\"_blank\"><img align=\"left\" width=\"48\" height=\"48\"  class=\"pfs\" src=\"" + headphoto + "\" alt=\"\"/></a>" + strblogcontent + "</p>";

                    }

                    //判断是否存在图片
                    string haspic = dr["haspic"] + "";
                    if (haspic == "1")
                    {
                        dr["strHasPic"] = "<img src=\"../images/smallpic.jpg\" alt=\"此创作包含图片\"/>";
                    }
                    else
                    {
                        dr["strHasPic"] = "";
                    }

                    //string blogbigtype = dr["BlogBigType"] + "";
                    //if (blogbigtype == "视频")
                    //{
                    //    dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                    //}
                    //else if (blogbigtype.ToLower() == "mp3")
                    //{
                    //    dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                    //}
                    //else
                    //{
                    //    dr["strVideoPic"] = "";
                    //}

                    string blogbigtype = dr["BlogBigType"] + "";
                    if (blogbigtype == "视频")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                        dr["BlogBigType"] = "<a href=\"../VideoList.aspx\" target=\"_blank\"><font color=\"#729830\">" + blogbigtype + "</font></a>";
                    }
                    else if (blogbigtype.ToLower() == "mp3")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                        dr["BlogBigType"] = "<a href=\"../MP3List.aspx\" target=\"_blank\"><font color=\"#729830\">" + blogbigtype + "</font></a>";
                    }
                    else
                    {
                        dr["strVideoPic"] = "";
                        dr["BlogBigType"] = "<a href=\"../TextList.aspx\" target=\"_blank\"><font color=\"#729830\">" + blogbigtype + "</font></a>";
                    }

                    string blogtypename = dr["BlogTypeName"] + "";
                    string blogtypeid = dr["BlogTypeID"] + "";
                    dr["BlogTypeName"] = "<a href=\"../cate/" + blogtypeid + ".aspx\" target=\"_blank\"><font color=\"#729830\">" + blogtypename + "</font></a>";
                }

                rptBlog.DataSource = dt;
                rptBlog.DataBind();
                lblMessage.Visible = false;
            }
            else
            {
                lblMessage.Visible = true;
                lblMessage.Text = "该用户暂时没有创作，<a href=\"../Index.aspx\"><font color=\"red\">返回首页</font></a>";
            }


            Users currentuinfo = UserBase.GetCurrentUser();
            if (currentuinfo != null)
            {
                hidCurrentUserID.Value = currentuinfo.ID;
            }
        }
        #endregion

        #region 加载该用户推荐的
        private void BindRecommand()
        {
            RecommandHelper rhelper = new RecommandHelper();

            DataTable dtpvBlog = rhelper.GetUserRecommand(userid, "10", "1");

            DataColumn dcTitle = new DataColumn("strTitle");
            dtpvBlog.Columns.Add(dcTitle);
            dtpvBlog.Columns.Add(new DataColumn("strHasPic"));
            dtpvBlog.Columns.Add(new DataColumn("strVideoPic"));

            if (dtpvBlog != null && dtpvBlog.Rows.Count > 0)
            {
                foreach (DataRow dr in dtpvBlog.Rows)
                {
                    string title = dr["title"] + "";
                    string strtitle = "";
                    strtitle = Tools.GetFirstString(title, 24);
                    dr["strTitle"] = strtitle;

                    //判断是否存在图片
                    string haspic = dr["haspic"] + "";
                    if (haspic == "1")
                    {
                        dr["strHasPic"] = "<img src=\"../images/smallpic.jpg\" alt=\"此创作包含图片\"/>";
                    }
                    else
                    {
                        dr["strHasPic"] = "";
                    }

                    string blogbigtype = dr["BlogBigType"] + "";
                    if (blogbigtype == "视频")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                    }
                    else if (blogbigtype.ToLower() == "mp3")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                    }
                    else
                    {
                        dr["strVideoPic"] = "";
                    }
                }
                divRecommand.Visible = true;
                rptRecommandOrder.DataSource = dtpvBlog;
                rptRecommandOrder.DataBind();
            }
            else
            {
                divRecommand.Visible = false;
            }   
        }
        #endregion

        #region 加载SEO信息
        private void BindSeo()
        {
            
            string nickname = litNickName1.Text;
            string systemkeyword = System.Configuration.ConfigurationManager.AppSettings["keyword"] + "";

            string author = System.Configuration.ConfigurationManager.AppSettings["author"] + "";
            string copyright = System.Configuration.ConfigurationManager.AppSettings["copyright"] + "";

            string keyword = nickname + " " + systemkeyword + " " + author;
            string description = litBrief.Text ;
            string title = author+"-"+nickname;

            strseo += "<title>" + title + "</title>\r\n";
            strseo += "<meta name=\"keywords\" content=\"" + keyword + "\" />\r\n";
            strseo += "<meta name=\"description\" content=\"" + description + "\" />\r\n";
            strseo += "<meta name=\"author\" content=\"" + author + "\" />\r\n";
            strseo += "<meta name=\"Copyright\" content=\"" + copyright + "\" />\r\n";
        }
        #endregion

        #region 加载该用户关注的创作人
        private void BindCareUser()
        {
            FriendHelper fhelper = new FriendHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "UsersID", userid);
            DataTable dt = fhelper.QueryFriendBySearchToTable(c, null, 0, 10, null);

            if (dt != null && dt.Rows.Count > 0)
            {
                dt.Columns.Add(new DataColumn("blognum"));
                dt.Columns.Add(new DataColumn("RealmName"));

                foreach (DataRow dr in dt.Rows)
                {
                    string friendid = dr["FriendUsersID"] + "";
                    //加载该用户的博客数
                    Users friendinfo = new Users();
                    UsersHelper uhelper = new UsersHelper();
                    friendinfo = uhelper.GetUsers(friendid);
                    string blognum = friendinfo.BlogNum.ToString();
                    dr["blognum"] = blognum;
                    dr["RealmName"] = friendinfo.RealmName;
                }
            }
            rptCareUser.DataSource = dt;
            rptCareUser.DataBind();
        }
        #endregion

        #region 加载用户精彩图文
        //private void BindBlogPic()
        //{
        //    BlogHelper bhelper = new BlogHelper();
        //    Criteria c = new Criteria();
        //    c.Add(CriteriaType.Equals, "Flag", 0);
        //    c.Add(CriteriaType.Equals, "HasPic", 1);
        //    c.Add(CriteriaType.Equals, "UsersID", userid);
        //    string[] fields = new string[] { "ID", "BlogBigType", "HasPic", "Title", "UsersID", "PVCount", "FirstPicPath", "Flag", "CreateDate" };
        //    DataTable dt = bhelper.QueryBlogBySearchToTable(c, new Order[] { new Order("CreateDate", OrderMode.Desc) }, 0, 6, fields);
        //    dt.Columns.Add(new DataColumn("strTitle"));

        //    foreach (DataRow dr in dt.Rows)
        //    {
        //        string title = dr["Title"] + "";
        //        title = Tools.GetFirstString(title, 30);
        //        dr["strTitle"] = title;
        //    }

        //    rptBlogPic.DataSource = dt;
        //    rptBlogPic.DataBind();
        //}
        #endregion

        #region 加载该用户正在阅读
        private void BindNowRead()
        {
            BlogHelper bhelper = new BlogHelper();
            DataSet ds = bhelper.GetUserNowRead(userid,10);

            DataColumn dcTitle = new DataColumn("strTitle");
            ds.Tables[0].Columns.Add(dcTitle);
            ds.Tables[0].Columns.Add(new DataColumn("strHasPic"));
            ds.Tables[0].Columns.Add(new DataColumn("strVideoPic"));

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string title = dr["title"] + "";
                    string strtitle = "";
                    strtitle = Tools.GetFirstString(title, 24);
                    dr["strTitle"] = strtitle;

                    //判断是否存在图片
                    string haspic = dr["haspic"] + "";
                    if (haspic == "1")
                    {
                        dr["strHasPic"] = "<img src=\"../images/smallpic.jpg\" alt=\"此创作包含图片\"/>";
                    }
                    else
                    {
                        dr["strHasPic"] = "";
                    }

                    string blogbigtype = dr["BlogBigType"] + "";
                    if (blogbigtype == "视频")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                    }
                    else if (blogbigtype.ToLower() == "mp3")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                    }
                    else
                    {
                        dr["strVideoPic"] = "";
                    }
                }
            }

            rptNowRead.DataSource = ds;
            rptNowRead.DataBind();
        }
        #endregion

        #region 加载该用户加入的小组
        //private void BindCompany()
        //{
        //    UserCompanyHelper uchelper = new UserCompanyHelper();
        //    DataSet dsCompany = uchelper.GetUserAddCompany(userid,10);
        //    if (dsCompany != null && dsCompany.Tables[0].Rows.Count > 0)
        //    {
        //        dsCompany.Tables[0].Columns.Add(new DataColumn("strCompanyName"));
        //        foreach (DataRow dr in dsCompany.Tables[0].Rows)
        //        {
        //            string companyname = dr["companyname"] + "";
        //            dr["strCompanyName"] = Tools.GetFirstString(companyname, 20);
        //        }

        //        rptCompany.DataSource = dsCompany;
        //        rptCompany.DataBind();
        //    }
        //    else
        //    {
        //        divAddCompany.Visible = false;
        //    }
        //}
        #endregion

        #region 加载该用户关注的小组
        private void BindCareCompany()
        {
            UserCareHelper uchelper = new UserCareHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "UsersID", userid);
            c.Add(CriteriaType.Equals, "ObjectType", 1);

            DataTable dt = uchelper.QueryUserCareBySearchToTable(c, null, 0, 10, null);
            dt.Columns.Add(new DataColumn("CompanyName"));
            dt.Columns.Add(new DataColumn("strCompanyName"));
            dt.Columns.Add(new DataColumn("BlogPVNum"));
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string objectid = dr["objectid"] + "";
                    Companys cinfo = new Companys();
                    CompanysHelper chelper = new CompanysHelper();
                    cinfo = chelper.GetCompanys(objectid);
                    string companyname = cinfo.CompanyName;
                    dr["CompanyName"] = companyname;
                    dr["strCompanyName"] =Tools.GetFirstString( companyname,20);
                    dr["BlogPVNum"] = cinfo.BlogPVNum.ToString();
                }

                rptCareCompany.DataSource = dt;
                rptCareCompany.DataBind();
            }
            else
            {
                divCareCompany.Visible = false;
            } 
        }
        #endregion

        #region 加载pv
        private void BindPV()
        {
            //判断今天是否已经记录过
            PVHelper phelper = new PVHelper();
            Criteria c = new Criteria();
            string ipaddress = IP.GetIPAddress();
            Users currentinfo = UserBase.GetCurrentUser();
            int count = 0;
            if (currentinfo == null)
            {
                count = phelper.GetPVCountToday(userid, "2", ipaddress, "");
            }
            else
            {
                count = phelper.GetPVCountToday(userid, "2", ipaddress, currentinfo.ID);
            }

            if (count == 0)
            {
                //插入PV
                PV pinfo = new PV();
                pinfo.ObjectID = userid;
                pinfo.ObjectType = 2;
                pinfo.IPAddress = ipaddress;
                if (currentinfo != null)
                {
                    pinfo.UsersID = currentinfo.ID;
                }
                phelper.AddPV(pinfo);

                Users uinfo = new Users();
                UsersHelper uhelper = new UsersHelper();
                uinfo = uhelper.GetUsers(userid);
                int blogpvnum = uinfo.BlogPVNum;
                blogpvnum = blogpvnum + 1;
                uinfo.BlogPVNum = blogpvnum;
                uhelper.EditUsers(uinfo);
            }
            
        }
        #endregion

        #region 加载用户图文榜
        private void BindTuWen()
        {
            BlogHelper bhelper = new BlogHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "Flag", 0);
            c.Add(CriteriaType.Equals, "UsersID", userid);
            c.Add(CriteriaType.Equals, "BlogBigType", "图文");

            string[] fields = new string[] { "ID", "BlogBigType", "HasPic", "Title", "UsersID", "PVCount", "Flag", "CreateDate" };
            DataTable dtpvBlog = bhelper.QueryBlogBySearchToTable(c, new Order[] { new Order("PVCount", OrderMode.Desc) }, 0, 10, fields);

            DataColumn dcTitle = new DataColumn("strTitle");
            dtpvBlog.Columns.Add(dcTitle);
            dtpvBlog.Columns.Add(new DataColumn("strHasPic"));
            dtpvBlog.Columns.Add(new DataColumn("strVideoPic"));

            if (dtpvBlog != null && dtpvBlog.Rows.Count > 0)
            {
                foreach (DataRow dr in dtpvBlog.Rows)
                {
                    string title = dr["title"] + "";
                    string strtitle = "";
                    strtitle = Tools.GetFirstString(title, 26);
                    dr["strTitle"] = strtitle;

                    //判断是否存在图片
                    string haspic = dr["haspic"] + "";
                    if (haspic == "1")
                    {
                        dr["strHasPic"] = "<img src=\"../images/smallpic.jpg\" alt=\"此创作包含图片\"/>";
                    }
                    else
                    {
                        dr["strHasPic"] = "";
                    }

                    string blogbigtype = dr["BlogBigType"] + "";
                    if (blogbigtype == "视频")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                    }
                    else if (blogbigtype.ToLower() == "mp3")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                    }
                    else
                    {
                        dr["strVideoPic"] = "";
                    }
                }

                divTuWen.Visible = true;
                rptTuWen.DataSource = dtpvBlog;
                rptTuWen.DataBind();
            }
            else
            {
                divTuWen.Visible = false;
            }
        }
        #endregion

        #region 加载用户视频榜
        private void BindVideo()
        {
            BlogHelper bhelper = new BlogHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "Flag", 0);
            c.Add(CriteriaType.Equals, "UsersID", userid);
            c.Add(CriteriaType.Equals, "BlogBigType", "视频");

            string[] fields = new string[] { "ID", "BlogBigType", "HasPic", "Title", "UsersID", "PVCount", "Flag", "CreateDate" };
            DataTable dtpvBlog = bhelper.QueryBlogBySearchToTable(c, new Order[] { new Order("PVCount", OrderMode.Desc) }, 0, 10, fields);

            DataColumn dcTitle = new DataColumn("strTitle");
            dtpvBlog.Columns.Add(dcTitle);
            dtpvBlog.Columns.Add(new DataColumn("strHasPic"));
            dtpvBlog.Columns.Add(new DataColumn("strVideoPic"));

            if (dtpvBlog != null && dtpvBlog.Rows.Count > 0)
            {
                foreach (DataRow dr in dtpvBlog.Rows)
                {
                    string title = dr["title"] + "";
                    string strtitle = "";
                    strtitle = Tools.GetFirstString(title, 26);
                    dr["strTitle"] = strtitle;

                    //判断是否存在图片
                    string haspic = dr["haspic"] + "";
                    if (haspic == "1")
                    {
                        dr["strHasPic"] = "<img src=\"../images/smallpic.jpg\" alt=\"此创作包含图片\"/>";
                    }
                    else
                    {
                        dr["strHasPic"] = "";
                    }

                    string blogbigtype = dr["BlogBigType"] + "";
                    if (blogbigtype == "视频")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                    }
                    else if (blogbigtype.ToLower() == "mp3")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                    }
                    else
                    {
                        dr["strVideoPic"] = "";
                    }
                }

                divVideo.Visible = true;
                rptVideo.DataSource = dtpvBlog;
                rptVideo.DataBind();
            }
            else
            {
                divVideo.Visible = false;
            }
        }
        #endregion

        #region 加载用户MP3榜
        private void BindMP3()
        {
            BlogHelper bhelper = new BlogHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "Flag", 0);
            c.Add(CriteriaType.Equals, "UsersID", userid);
            c.Add(CriteriaType.Equals, "BlogBigType", "MP3");

            string[] fields = new string[] { "ID", "BlogBigType", "HasPic", "Title", "UsersID", "PVCount", "Flag", "CreateDate" };
            DataTable dtpvBlog = bhelper.QueryBlogBySearchToTable(c, new Order[] { new Order("PVCount", OrderMode.Desc) }, 0, 10, fields);

            DataColumn dcTitle = new DataColumn("strTitle");
            dtpvBlog.Columns.Add(dcTitle);
            dtpvBlog.Columns.Add(new DataColumn("strHasPic"));
            dtpvBlog.Columns.Add(new DataColumn("strVideoPic"));

            if (dtpvBlog != null && dtpvBlog.Rows.Count > 0)
            {
                foreach (DataRow dr in dtpvBlog.Rows)
                {
                    string title = dr["title"] + "";
                    string strtitle = "";
                    strtitle = Tools.GetFirstString(title, 26);
                    dr["strTitle"] = strtitle;

                    //判断是否存在图片
                    string haspic = dr["haspic"] + "";
                    if (haspic == "1")
                    {
                        dr["strHasPic"] = "<img src=\"../images/smallpic.jpg\" alt=\"此创作包含图片\"/>";
                    }
                    else
                    {
                        dr["strHasPic"] = "";
                    }

                    string blogbigtype = dr["BlogBigType"] + "";
                    if (blogbigtype == "视频")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/smallvideo.jpg\" alt=\"视频\"/>";
                    }
                    else if (blogbigtype.ToLower() == "mp3")
                    {
                        dr["strVideoPic"] = "<img src=\"../images/mp3.png\" alt=\"mp3\"/>";
                    }
                    else
                    {
                        dr["strVideoPic"] = "";
                    }
                }

                divMP3.Visible = true;
                rptMP3.DataSource = dtpvBlog;
                rptMP3.DataBind();
            }
            else
            {
                divMP3.Visible = false;
            }
        }
        #endregion

        #region 加载广告
        private void BindAd()
        {
            AdPositionHelper aphelper = new AdPositionHelper();
            string result1 = aphelper.BindAd(userid, "6", 1);
            litAd1.Text = result1;
            string result2 = aphelper.BindAd(userid, "7", 1);
            litAd2.Text = result2;
            string result3 = aphelper.BindAd(userid, "8", 1);
            litAd3.Text = result3;
            string result4 = aphelper.BindAd(userid, "9", 1);
            litAd4.Text = result4;
            string result5 = aphelper.BindAd(userid, "10", 1);
            litAd5.Text = result5;
        }
        #endregion
    }
}